package com.foo.web.controller.wechat;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.foo.common.annotation.Log;
import com.foo.common.enums.BusinessType;
import com.foo.wechat.domain.WxOrder;
import com.foo.wechat.service.IWxOrderService;
import com.foo.common.core.controller.BaseController;
import com.foo.common.core.domain.AjaxResult;
import com.foo.common.utils.poi.ExcelUtil;
import com.foo.common.core.page.TableDataInfo;

/**
 * 领养订单Controller
 *
 * @author foo
 * @date 2025-11-17
 */
@Controller
@RequestMapping("/wechat/WxOrder")
public class WxOrderController extends BaseController
{
    private String prefix = "wechat/WxOrder";

    @Autowired
    private IWxOrderService wxOrderService;

    @RequiresPermissions("wechat:WxOrder:view")
    @GetMapping()
    public String WxOrder()
    {
        return prefix + "/WxOrder";
    }

    /**
     * 查询领养订单列表
     */
    @RequiresPermissions("wechat:WxOrder:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WxOrder wxOrder)
    {
        startPage();
        List<WxOrder> list = wxOrderService.selectWxOrderList(wxOrder);
        return getDataTable(list);
    }


    /**
     * 领养订单详情
     */
    @GetMapping("/detail/{orderId}")
    public String detail(@PathVariable("orderId") Long orderId, ModelMap mmap)
    {
        WxOrder wxOrder = wxOrderService.selectWxOrderById(orderId);
        mmap.put("wxOrder", wxOrder);
        return prefix + "/detail";
    }



    /**
     * 修改领养订单
     */
    @GetMapping("/edit/{orderId}")
    public String edit(@PathVariable("orderId") Long orderId, ModelMap mmap)
    {
        WxOrder wxOrder = wxOrderService.selectWxOrderById(orderId);
        mmap.put("wxOrder", wxOrder);
        return prefix + "/edit";
    }

    /**
     * 修改保存领养订单
     */
    @RequiresPermissions("wechat:WxOrder:edit")
    @Log(title = "领养订单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WxOrder wxOrder)
    {
        return toAjax(wxOrderService.updateWxOrder(wxOrder));
    }

    /**
     * 删除领养订单
     */
    @RequiresPermissions("wechat:WxOrder:remove")
    @Log(title = "领养订单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wxOrderService.deleteWxOrderByIds(ids));
    }
}
